﻿namespace FastCode.Helper
{
    public class ReflectionHelper
    {
        /// <summary>
        /// 指定类型是否可为空
        /// </summary>
        /// <param name="type"></param>
        /// <returns></returns>
        public static bool IsNullable(Type type)
        {
            // Nullable value types are instances of the Nullable<T> struct.
            if (Nullable.GetUnderlyingType(type) != null)
                return true;

            // Reference types are always nullable.
            if (!type.IsValueType)
                return true;

            // Value types are not nullable.
            return false;
        }

    }
}
